//
//  FeedbackDetailsCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/9/1.
//

#import "FeedbackDetailsCell.h"
@interface FeedbackDetailsCell()
@property(nonatomic,strong) UIView *bjview;
@property(nonatomic,strong) UIImageView *avatarImage;
@property(nonatomic,strong) UIImageView *iconImage;
@property(nonatomic,strong) UIView *contentLabelbj;
@property(nonatomic,strong) UILabel *contentLabel;

@end
@implementation FeedbackDetailsCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
        self.contentView.backgroundColor = rgba(255, 255, 255, 1);
    }
    return self;
}

- (void)setupUI
{
    self.bjview = [[UIView alloc]initWithFrame:CGRectMake(16, 0, APPwidth-32, 50)];
    self.bjview.backgroundColor = rgba(245, 245, 250, 1);
    [self.contentView addSubview:self.bjview];
    
    
    self.avatarImage = [[UIImageView alloc]initWithFrame:CGRectMake(16, 16, 40, 40)];
    self.avatarImage.layer.cornerRadius = 20;
    self.avatarImage.layer.masksToBounds = YES;
    self.avatarImage.image = CoachsBookImageName(@"注销账号");
    [self.bjview addSubview:self.avatarImage];
    
    self.iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(60, 30, 10, 12)];
    [self.bjview addSubview:self.iconImage];
    
    self.contentLabelbj = [[UIView alloc]initWithFrame:CGRectMake(65, 16, APPwidth-32-65-20, 40)];
    self.contentLabelbj.layer.cornerRadius = 10;
    self.contentLabelbj.layer.masksToBounds = YES;
    [self.bjview addSubview:self.contentLabelbj];
    
    
    self.contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 16, APPwidth-32-65-30, 40)];
    self.contentLabel.textColor = rgba(51, 51, 51, 1);
    self.contentLabel.font = kPingFangRegular(16);
    self.contentLabel.numberOfLines = 0;
    [self.bjview addSubview:self.contentLabel];
}

-(void)cellFillWithModel:(FeedbackDetailsModel *)model WithRow:(NSInteger)row
{
    self.contentLabel.text = model.FeedbackContent;
    
    
    CGFloat contentLabelH = [LongHelper textHeight:model.FeedbackContent WithUIFont:kPingFangRegular(16) AndWidth:APPwidth-32-65-30];
    contentLabelH = contentLabelH>30?contentLabelH:30;
    if (model.FeedbackType == 0) {
        self.avatarImage.frame = CGRectMake(16, 16, 40, 40);
        self.iconImage.frame = CGRectMake(60, 30, 10, 12);
        self.contentLabelbj.frame = CGRectMake(65, 16, APPwidth-32-65-20, contentLabelH+10);
        self.contentLabel.frame = CGRectMake(75, 21, APPwidth-32-65-40, contentLabelH);
        self.iconImage.image = CoachsBookImageName(@"left_w");
        self.contentLabelbj.backgroundColor = [UIColor whiteColor];
    }
    else{
        self.avatarImage.frame = CGRectMake(APPwidth-32-56, 16, 40, 40);
        self.iconImage.frame = CGRectMake(APPwidth-32-70, 30, 10, 12);
        self.contentLabelbj.frame = CGRectMake(20, 16, APPwidth-32-65-20, contentLabelH+10);
        self.contentLabel.frame = CGRectMake(30, 21, APPwidth-32-65-40, contentLabelH);
        self.iconImage.image = CoachsBookImageName(@"right_b");
        self.contentLabelbj.backgroundColor = rgba(22, 120, 255, 1);
    }
    self.bjview.frame = CGRectMake(16, 0, APPwidth-32, 34+contentLabelH);
    if (row == 0) {
        [LongHelper addCornerWithRoundedRect:CGRectMake(0, 0, APPwidth-32, 34+contentLabelH) RoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10) roundView:self.bjview];
    }
    else if (row==2)
    {
        [LongHelper addCornerWithRoundedRect:CGRectMake(0, 0, APPwidth-32, 34+contentLabelH) RoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10) roundView:self.bjview];
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
